<?php namespace Home\Model;

use Framework\Model\Model;

class Ask extends Model
{
	public $table='ask';

	public function add()
	{
		$sql ="INSERT INTO ask (title,category_id,content,create_at,user_id)
		VALUE(?,?,?,?,?)";

		$data = [
			'title'=>$_POST['title'],
			'category_id'=>$_POST['category_id'],
			'content'=>$_POST['content'],
			
			'create_at'=>time(),
			'user_id'=>$_SESSION['id']
		];
		if($this->execute($sql,$data))
		{
			return $this->getInsertId();
		}
		else
		{
			$this->error ='添加失败';
			return false;
		}
	}



}